import java.awt.Canvas;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;

public class MyCanvas extends Canvas {
	public String partType;
	public static int number = 0;

	MyCanvas() {
		setSize(400, 200);
		setBackground(Color.white);
	}

	public void paint(Graphics g) {// graphics object created by D and passed to
									// this
		Rectangle rect = getBounds();
		for (int i = 0; i < 100; i++) {
			g.setColor(new Color(rando(0, 255), rando(0, 255), rando(0, 255)));
			int x = rando(-rect.width, rect.width);
			int y = rando(-rect.height, rect.height);
			int width = rando(5, rect.width);
			int height = rando(5, rect.height);
			switch (rando(0, 4)) {
			case 0:
				g.drawRect(x, y, width, height);
				break;
			case 1:
				g.fillRect(x, y, width, height);
				break;
			case 2:
				g.drawOval(x, y, width, height);
				break;
			case 3:
				g.fillRect(x, y, width, height);
				break;

			}

		}

	}

	public int rando(int low, int high) {
		return (((int) ((high - low + 1) * (Math.random()))) + low);
	}

}
